# Copyright (c) 2011 BSD, Roger Lew [see LICENSE.txt]
# This software is funded in part by NIH Grant P20 RR016454.
import numpy as np
import pylab
import mpl_toolkits.mplot3d.axes3d as p3

from qsturng import qsturng,p_keys,v_keys
##from qsturng.make_tbls import T,R

inf = float('inf')

# from Harter's table
q0999 = """\
44.69 60.42 70.77 78.43 84.49 89.46 93.67 97.30 100.5 103.3 105.9 108.2 110.4 112.3 114.2 115.9 117.4 118.9 120.3 131.0 138.3 148.0 154.7 159.7
18.28 23.32 26.65 29.13 31.11 32.74 34.12 35.33 36.39 37.34 38.20 38.98 39.69 40.35 40.97 41.54 42.07 42.58 43.05 46.68 49.16 52.51 54.81 56.53
12.18 14.98 16.84 18.23 19.34 20.26 21.04 21.73 22.33 22.87 23.36 23.81 24.21 24.59 24.94 25.27 25.58 25.87 26.14 28.24 29.68 31.65 32.98 34.00
9.714 11.67 12.96 13.93 14.71 15.35 15.91 16.39 16.82 17.18 17.53 17.85 18.13 18.41 18.66 18.89 19.10 19.31 19.51 21.01 22.03 23.45 24.41 25.15
8.427 9.960 10.97 11.72 12.32 12.82 13.25 13.63 13.96 14.26 14.53 14.78 15.00 15.21 15.41 15.59 15.78 15.94 16.09 17.28 18.10 19.22 20.00 20.58
7.648 8.930 9.768 10.40 10.90 11.32 11.67 11.99 12.27 12.52 12.74 12.95 13.14 13.32 13.48 13.64 13.78 13.92 14.05 15.06 15.74 16.69 17.35 17.85
7.129 8.250 8.977 9.522 9.958 10.32 10.63 10.90 11.15 11.36 11.56 11.74 11.91 12.06 12.20 12.34 12.46 12.58 12.69 13.57 14.17 15.01 15.59 16.02
6.761 7.768 8.419 8.906 9.295 9.619 9.896 10.14 10.35 10.55 10.72 10.89 11.03 11.17 11.30 11.42 11.53 11.64 11.74 12.52 13.07 13.82 14.34 14.74
6.487 7.411 8.006 8.449 8.804 9.099 9.352 9.573 9.769 9.946 10.11 10.25 10.39 10.51 10.63 10.74 10.84 10.94 11.03 11.75 12.25 12.94 13.42 13.79
6.275 7.135 7.687 8.098 8.426 8.699 8.933 9.137 9.319 9.482 9.630 9.766 9.891 10.01 10.12 10.22 10.31 10.40 10.49 11.15 11.61 12.25 12.70 13.03
6.106 6.917 7.435 7.820 8.127 8.382 8.601 8.792 8.962 9.115 9.253 9.380 9.497 9.606 9.707 9.802 9.891 9.975 10.05 10.68 11.11 11.71 12.12 12.44
5.969 6.740 7.231 7.595 7.885 8.126 8.332 8.513 8.673 8.817 8.948 9.068 9.178 9.280 9.376 9.465 9.549 9.629 9.704 10.29 10.70 11.27 11.66 11.96
5.855 6.593 7.062 7.409 7.685 7.914 8.110 8.282 8.434 8.571 8.695 8.809 8.914 9.011 9.102 9.187 9.267 9.342 9.414 9.972 10.36 10.90 11.28 11.57
5.760 6.470 6.920 7.252 7.517 7.736 7.924 8.088 8.234 8.364 8.483 8.592 8.692 8.785 8.872 8.953 9.030 9.102 9.170 9.703 10.08 10.59 10.95 11.23
5.678 6.365 6.799 7.119 7.374 7.585 7.765 7.923 8.063 8.189 8.303 8.407 8.504 8.593 8.676 8.754 8.828 8.897 8.962 9.475 9.832 10.33 10.68 10.94
5.608 6.274 6.695 7.004 7.250 7.454 7.629 7.781 7.916 8.037 8.147 8.248 8.341 8.427 8.507 8.583 8.653 8.720 8.783 9.277 9.623 10.10 10.44 10.69
5.546 6.195 6.604 6.905 7.143 7.341 7.510 7.657 7.788 7.905 8.012 8.109 8.199 8.283 8.361 8.433 8.502 8.566 8.627 9.106 9.440 9.904 10.23 10.48
5.492 6.126 6.524 6.817 7.049 7.241 7.405 7.549 7.676 7.790 7.893 7.988 8.075 8.156 8.232 8.302 8.369 8.431 8.491 8.955 9.279 9.729 10.04 10.29
5.444 6.065 6.454 6.740 6.966 7.153 7.313 7.453 7.576 7.687 7.788 7.880 7.965 8.044 8.118 8.186 8.251 8.312 8.370 8.821 9.136 9.575 9.881 10.12
5.297 5.877 6.238 6.502 6.711 6.884 7.031 7.159 7.272 7.374 7.467 7.551 7.629 7.701 7.768 7.831 7.890 7.946 7.999 8.411 8.699 9.100 9.380 9.595
5.156 5.698 6.033 6.277 6.469 6.628 6.763 6.880 6.984 7.077 7.161 7.239 7.310 7.375 7.437 7.494 7.548 7.598 7.646 8.021 8.283 8.646 8.901 9.096
5.022 5.527 5.838 6.063 6.240 6.385 6.509 6.616 6.710 6.795 6.872 6.942 7.007 7.066 7.122 7.174 7.223 7.268 7.312 7.651 7.887 8.214 8.442 8.618
4.893 5.365 5.653 5.860 6.022 6.155 6.268 6.365 6.451 6.528 6.598 6.661 6.720 6.773 6.824 6.870 6.914 6.956 6.995 7.299 7.510 7.802 8.005 8.161
4.771 5.211 5.476 5.667 5.815 5.937 6.039 6.128 6.206 6.275 6.338 6.395 6.448 6.496 6.541 6.583 6.623 6.660 6.695 6.966 7.153 7.410 7.589 7.726
4.654 5.063 5.309 5.484 5.619 5.730 5.823 5.903 5.973 6.036 6.092 6.144 6.191 6.234 6.274 6.312 6.347 6.380 6.411 6.651 6.816 7.041 7.196 7.314"""

# from R's qtukey
ch0999 = """\
34.71363 42.41291 46.93637 50.12041 52.56414 54.53916 56.1916 57.60896 58.8477 59.94634 60.93227 61.82566 62.64179 63.39248 64.08705 64.73302 65.33649 65.90249 66.43524 70.51358 73.2792 77.022 79.57999 81.51381
18.27676 23.70372 27.66839 30.92112 33.65335 35.96129 37.93053 39.63366 41.12687 42.45227 43.64135 44.71793 45.70032 46.60284 47.43685 48.21152 48.93432 49.61143 50.24801 55.09543 58.35526 62.73058 NaN NaN
12.18349 14.98292 16.82169 18.18959 19.27307 20.16572 20.92173 21.5754 22.14981 22.6612 23.1214 23.53926 23.92159 24.27368 24.59977 24.90327 25.18698 25.45321 25.70390 27.62455 28.92645 30.68462 31.88276 32.78646
9.713988 11.67150 12.96211 13.93128 14.70736 15.35395 15.90750 16.39097 16.81976 17.20472 17.55378 17.87292 18.16674 18.43888 18.69225 18.92921 19.15172 19.36141 19.55963 21.10438 22.17964 23.67365 24.72421 25.53721
8.42698 9.95952 10.96508 11.71909 12.32246 12.82485 13.25468 13.62981 13.96223 14.26039 14.53046 14.77711 15.00393 15.21377 15.40888 15.59114 15.76205 15.92291 16.07478 17.25041 18.05861 19.16362 19.92501 20.50327
7.647901 8.9304 9.76791 10.39527 10.89745 11.31600 11.67458 11.98801 12.26622 12.5162 12.74304 12.95058 13.14179 13.31900 13.48407 13.63853 13.78364 13.92043 14.0498 15.05894 15.76135 16.73409 17.41331 17.93461
7.129484 8.2495 8.977466 9.521926 9.957574 10.32069 10.63184 10.90390 11.14544 11.36252 11.55953 11.73979 11.90585 12.05973 12.20304 12.33711 12.46300 12.58164 12.69378 13.56563 14.16745 14.98978 15.55369 15.97957
6.761231 7.768013 8.419424 8.905763 9.294625 9.618669 9.896353 10.13919 10.35484 10.54871 10.72472 10.88582 11.03429 11.17192 11.30016 11.42018 11.53293 11.63923 11.73976 12.52344 13.06765 13.81844 14.34025 14.73922
6.486847 7.410581 8.005724 8.449237 8.803547 9.098681 9.35156 9.572706 9.76913 9.94574 10.10612 10.25295 10.38831 10.51382 10.63081 10.74032 10.84323 10.94029 11.03210 11.74889 12.24789 12.93803 13.41863 13.78641
6.274836 7.135253 7.687425 8.098164 8.425979 8.698905 8.932695 9.137127 9.318703 9.481974 9.630251 9.766021 9.891198 10.00729 10.11550 10.21682 10.31205 10.40187 10.48685 11.15058 11.61280 12.25156 12.69534 13.03390
6.106279 6.91693 7.435287 7.820189 8.12708 8.382438 8.601105 8.792278 8.962063 9.114727 9.253373 9.38033 9.49739 9.605961 9.707173 9.801944 9.89103 9.975062 10.05457 10.67588 11.10888 11.70769 12.12409 12.44205
5.969157 6.739728 7.23082 7.594861 7.884832 8.125965 8.332372 8.512783 8.672985 8.817022 8.947828 9.067606 9.17805 9.280489 9.37599 9.465418 9.549488 9.628795 9.70384 10.29053 10.69980 11.26660 11.66155 11.96376
5.855486 6.59312 7.061791 7.408654 7.684676 7.914067 8.110342 8.28185 8.434118 8.571005 8.69531 8.80913 8.914079 9.011422 9.102175 9.18716 9.267056 9.342429 9.413756 9.971576 10.36099 10.90089 11.27758 11.56615
5.75976 6.469871 6.919794 7.25228 7.516614 7.736155 7.923923 8.087949 8.233544 8.364413 8.48324 8.592038 8.692351 8.785393 8.872135 8.953365 9.029733 9.101778 9.169958 9.703287 10.07579 10.59255 10.95332 11.22976
5.678062 6.364847 6.798873 7.119157 7.373561 7.584728 7.765256 7.922908 8.062815 8.18855 8.302702 8.40721 8.503561 8.592925 8.676235 8.754251 8.827596 8.89679 8.962273 9.474561 9.832479 10.32921 10.67611 10.94196
5.607535 6.274307 6.694689 7.004493 7.250363 7.454325 7.62862 7.780781 7.915784 8.037089 8.147205 8.248007 8.340935 8.427118 8.50746 8.582693 8.653421 8.720146 8.78329 9.277316 9.622546 10.10183 10.43666 10.69332
5.546045 6.195466 6.604015 6.904725 7.143183 7.340885 7.509759 7.657142 7.787874 7.90532 8.011917 8.109487 8.199427 8.282833 8.360583 8.433385 8.501825 8.56639 8.62749 9.105518 9.439614 9.903576 10.22784 10.47649
5.491965 6.126204 6.524398 6.817144 7.049108 7.24132 7.40544 7.548628 7.675609 7.789664 7.893167 7.987894 8.075205 8.156167 8.231632 8.302292 8.368716 8.431377 8.490674 8.954573 9.278821 9.729218 10.04412 10.28569
5.444038 6.064884 6.453941 6.739658 6.965888 7.153249 7.313164 7.452642 7.576303 7.687355 7.788118 7.880325 7.965305 8.044099 8.117538 8.186297 8.25093 8.3119 8.369594 8.820925 9.136395 9.574684 9.881222 10.11645
5.296794 5.876876 6.238118 6.502418 6.711157 6.88371 7.030776 7.158903 7.272398 7.374245 7.466599 7.551068 7.628883 7.701007 7.76821 7.831112 7.890226 7.945979 7.998727 8.411155 8.699333 9.099793 9.380049 9.595255
5.156164 5.697886 6.032952 6.277078 6.469317 6.62788 6.762789 6.88016 6.984007 7.077106 7.161459 7.238555 7.309533 7.375285 7.436521 7.493815 7.547639 7.598385 7.646382 8.02126 8.282898 8.64629 8.900596 9.095928
5.021824 5.527466 5.837921 6.063066 6.239766 6.385137 6.508566 6.615768 6.71048 6.795286 6.872042 6.942129 7.006601 7.066281 7.121825 7.173763 7.222528 7.268481 7.311925 7.650645 7.886521 8.213621 8.442299 8.617877
4.893462 5.365187 5.652529 5.859844 6.021937 6.154896 6.267513 6.365126 6.451216 6.528185 6.597754 6.661203 6.719506 6.773423 6.82356 6.870402 6.91435 6.955735 6.994836 7.298894 7.509874 7.801574 8.004996 8.160953
4.770784 5.210645 5.476306 5.666901 5.815294 5.936607 6.039074 6.127678 6.205662 6.275256 6.338058 6.395251 6.447736 6.496213 6.54124 6.583265 6.622655 6.659714 6.694698 6.965778 7.152906 7.4104 7.58918 7.725833
4.653508 5.063453 5.308804 5.483754 5.619333 5.729754 5.822728 5.902906 5.973307 6.036 6.092467 6.143802 6.190836 6.234215 6.274452 6.311958 6.347071 6.38007 6.411188 6.651228 6.815814 7.040804 7.19601 7.314094"""

q = np.array([map(float, L.split()) for L in q0999.split('\n')])
ch = np.array([map(float, L.split()) for L in ch0999.split('\n')])
rs = [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,30,40,60,80,100]
rs_mesh = np.array([rs for i in range(25)])
vs = [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,24,30,40,60,120,inf]
vs_mesh = np.array([list(t) for t in zip(*[range(1,1+len(vs)) for i in range(len(rs))])])

ch_ne = (ch-q)/q

from pprint import pprint as pp
pp([' '.join(['%.2f'%e for e in L]) for L in ch_ne*100])

q0975 = """\
8.776 11.94 14.02 15.54 16.75 17.74 18.58 19.31 19.95 20.52 21.03 21.49 21.91 22.30 22.67 23.01 23.32 23.62 23.89 26.03 27.47 29.42 30.74 31.74
5.907 7.661 8.808 9.659 10.33 10.89 11.36 11.77 12.14 12.46 12.75 13.01 13.25 13.47 13.68 13.87 14.05 14.22 14.38 15.62 16.46 17.58 18.37 18.95
4.943 6.244 7.088 7.715 8.213 8.625 8.975 9.279 9.548 9.788 10.00 10.20 10.38 10.55 10.71 10.85 10.99 11.11 11.23 12.16 12.78 13.65 14.23 14.68
4.474 5.558 6.257 6.775 7.186 7.526 7.816 8.068 8.291 8.490 8.670 8.834 8.984 9.124 9.253 9.373 9.486 9.592 9.693 10.47 11.00 11.72 12.21 12.59
4.198 5.158 5.772 6.226 6.586 6.884 7.138 7.359 7.554 7.729 7.887 8.031 8.163 8.285 8.399 8.505 8.605 8.698 8.787 9.469 9.937 10.57 11.01 11.34
4.018 4.897 5.455 5.867 6.194 6.464 6.694 6.894 7.071 7.230 7.373 7.504 7.624 7.735 7.838 7.935 8.025 8.110 8.191 8.812 9.239 9.822 10.22 10.53
3.891 4.714 5.233 5.616 5.919 6.169 6.382 6.567 6.731 6.878 7.011 7.132 7.244 7.347 7.442 7.532 7.616 7.694 7.769 8.346 8.743 9.286 9.660 9.944
3.797 4.578 5.069 5.430 5.715 5.950 6.151 6.325 6.479 6.617 6.742 6.856 6.961 7.057 7.148 7.232 7.311 7.385 7.455 7.999 8.373 8.885 9.238 9.506
3.725 4.474 4.943 5.286 5.558 5.782 5.972 6.138 6.284 6.415 6.534 6.642 6.742 6.834 6.920 7.000 7.075 7.145 7.212 7.729 8.085 8.574 8.910 9.166
3.667 4.391 4.843 5.173 5.433 5.648 5.830 5.989 6.130 6.255 6.369 6.473 6.568 6.656 6.738 6.815 6.887 6.955 7.018 7.514 7.856 8.324 8.648 8.894
3.620 4.324 4.761 5.080 5.332 5.539 5.715 5.868 6.004 6.125 6.235 6.335 6.426 6.511 6.591 6.664 6.734 6.799 6.860 7.338 7.668 8.120 8.433 8.670
3.582 4.269 4.694 5.004 5.248 5.449 5.620 5.768 5.899 6.017 6.123 6.220 6.309 6.391 6.468 6.539 6.606 6.670 6.729 7.192 7.511 7.950 8.253 8.484
3.549 4.222 4.638 4.940 5.178 5.373 5.540 5.684 5.812 5.926 6.029 6.123 6.210 6.290 6.364 6.434 6.499 6.560 6.618 7.068 7.379 7.806 8.100 8.325
3.521 4.182 4.589 4.885 5.117 5.309 5.471 5.612 5.736 5.848 5.948 6.040 6.125 6.205 6.275 6.343 6.407 6.467 6.523 6.962 7.265 7.682 7.969 8.189
3.497 4.148 4.548 4.838 5.065 5.253 5.412 5.550 5.671 5.780 5.879 5.969 6.051 6.128 6.199 6.265 6.327 6.386 6.441 6.870 7.167 7.574 7.856 8.070
3.476 4.118 4.511 4.797 5.020 5.204 5.360 5.495 5.615 5.722 5.818 5.906 5.987 6.062 6.132 6.197 6.258 6.315 6.369 6.790 7.080 7.479 7.756 7.966
3.458 4.091 4.479 4.760 4.980 5.161 5.315 5.448 5.565 5.670 5.765 5.851 5.931 6.004 6.073 6.137 6.196 6.253 6.306 6.719 7.004 7.396 7.667 7.874
3.441 4.068 4.451 4.728 4.945 5.123 5.274 5.405 5.521 5.624 5.717 5.803 5.881 5.953 6.020 6.083 6.142 6.197 6.250 6.656 6.936 7.322 7.589 7.792
3.427 4.047 4.426 4.699 4.914 5.089 5.238 5.367 5.481 5.583 5.675 5.759 5.836 5.907 5.974 6.035 6.093 6.148 6.199 6.599 6.876 7.255 7.518 7.718
3.381 3.982 4.347 4.610 4.816 4.984 5.126 5.250 5.358 5.455 5.543 5.623 5.696 5.764 5.827 5.886 5.941 5.993 6.042 6.422 6.685 7.046 7.295 7.486
3.337 3.919 4.271 4.523 4.720 4.881 5.017 5.134 5.238 5.330 5.414 5.490 5.560 5.624 5.684 5.740 5.792 5.841 5.888 6.248 6.497 6.838 7.075 7.255
3.294 3.858 4.196 4.439 4.627 4.780 4.910 5.022 5.120 5.208 5.287 5.360 5.426 5.487 5.543 5.596 5.646 5.692 5.736 6.077 6.311 6.633 6.855 7.025
3.251 3.798 4.124 4.356 4.536 4.682 4.806 4.912 5.006 5.089 5.164 5.232 5.295 5.352 5.406 5.456 5.502 5.546 5.588 5.908 6.127 6.428 6.636 6.795
3.210 3.739 4.053 4.275 4.447 4.587 4.704 4.805 4.894 4.972 5.043 5.107 5.166 5.221 5.271 5.318 5.362 5.403 5.442 5.741 5.946 6.225 6.418 6.564
3.170 3.682 3.984 4.197 4.361 4.494 4.605 4.700 4.784 4.858 4.925 4.985 5.041 5.092 5.139 5.183 5.224 5.262 5.299 5.577 5.766 6.023 6.199 6.333"""

ch0975 = """\
8.754609 11.93654 14.01883 15.54388 16.73261 17.69882 18.50863 19.20348 19.81081 20.34954 20.83319 21.27169 21.67255 22.04156 22.38325 22.70128 22.99859 23.27764 23.54043 25.55531 26.92145 28.76449 30.01834 30.96267
5.906512 7.660809 8.807694 9.659486 10.33455 10.89171 11.36463 11.77444 12.13528 12.45707 12.74705 13.01065 13.25207 13.47457 13.68079 13.87285 14.0525 14.22119 14.38013 15.60254 16.43869 17.58255 18.37294 18.97462
4.943299 6.243653 7.088175 7.715441 8.213296 8.624981 8.975175 9.279323 9.547741 9.787656 10.00432 10.20168 10.38276 10.54992 10.70507 10.84975 10.98520 11.1125 11.23251 12.15564 12.78338 13.63102 14.20780 14.64243
4.473697 5.558021 6.256746 6.774849 7.186119 7.526468 7.816258 8.068193 8.29074 8.489827 8.669767 8.833794 8.984395 9.123523 9.252737 9.373304 9.486267 9.592491 9.692706 10.46633 10.99626 11.71843 12.21417 12.58943
4.198356 5.157934 5.771726 6.225786 6.585984 6.884078 7.137979 7.358817 7.553999 7.728701 7.886687 8.030778 8.163141 8.285478 8.39915 8.50526 8.604715 8.698271 8.786564 9.46897 9.93692 10.57455 11.01209 11.34346
4.018126 4.89697 5.455416 5.867491 6.194047 6.464206 6.694309 6.89448 7.07144 7.229879 7.373204 7.503965 7.624121 7.735211 7.838463 7.934874 8.025263 8.110315 8.190601 8.811827 9.238631 9.82158 10.22277 10.52728
3.891242 4.713745 5.233355 5.615822 5.918558 6.168871 6.382021 6.567438 6.731365 6.878155 7.010963 7.132153 7.243536 7.346536 7.442288 7.531714 7.615573 7.694493 7.769007 8.346068 8.743072 9.285954 9.6598 9.943524
3.797179 4.578204 5.069099 5.429584 5.714571 5.950053 6.150505 6.324847 6.478974 6.616991 6.741871 6.855836 6.960592 7.057474 7.147552 7.23169 7.3106 7.384873 7.455009 7.998508 8.372798 8.885096 9.23818 9.506326
3.724709 4.473959 4.942779 5.286304 5.557558 5.781535 5.972113 6.137828 6.28431 6.415473 6.534151 6.642459 6.74202 6.834104 6.919727 6.99971 7.074731 7.14535 7.212041 7.729088 8.085445 8.573622 8.910404 9.16638
3.667187 4.391335 4.842664 5.172714 5.433025 5.647814 5.830493 5.989294 6.129639 6.255295 6.368982 6.472734 6.568107 6.656321 6.738347 6.814975 6.886852 6.954516 7.01842 7.514026 7.855821 8.32439 8.647897 8.89392
3.620433 4.32426 4.761396 5.080481 5.33187 5.539153 5.715367 5.8685 6.003766 6.124936 6.234519 6.334519 6.426441 6.511461 6.59052 6.664376 6.733655 6.798876 6.860474 7.338315 7.668015 8.120267 8.432696 8.67039
3.581691 4.268736 4.694126 5.004119 5.248093 5.449127 5.61995 5.768351 5.899448 6.016789 6.122933 6.219787 6.308813 6.391153 6.467717 6.539243 6.606337 6.669502 6.72916 7.192014 7.511488 7.949915 8.252943 8.483562
3.549067 4.222023 4.637534 4.939866 5.177582 5.373332 5.539592 5.683981 5.811505 5.925628 6.028848 6.123026 6.209586 6.289641 6.364079 6.433617 6.498845 6.560253 6.618253 7.06828 7.37898 7.805525 8.100462 8.324995
3.521222 4.182183 4.589272 4.88506 5.117423 5.308649 5.470994 5.611939 5.736392 5.847746 5.948448 6.04032 6.124754 6.202838 6.27544 6.343261 6.406877 6.466767 6.523331 6.962244 7.265325 7.681532 7.969424 8.188658
3.497178 4.147807 4.54763 4.837765 5.065498 5.252804 5.411754 5.54971 5.671494 5.780442 5.878953 5.968816 6.051397 6.127762 6.198762 6.265085 6.327293 6.385856 6.441167 6.870348 7.166742 7.573863 7.855556 8.070124
3.476209 4.117844 4.511336 4.79654 5.020227 5.204105 5.360084 5.49542 5.614864 5.721698 5.818285 5.906383 5.987334 6.062187 6.131777 6.196779 6.257747 6.31514 6.369345 6.789931 7.080406 7.479469 7.755656 7.966076
3.45776 4.091498 4.479424 4.760287 4.98041 5.161265 5.314621 5.447643 5.565017 5.669982 5.764865 5.851399 5.930905 6.004416 6.072755 6.136585 6.19645 6.252805 6.306027 6.71896 7.004155 7.396015 7.667275 7.87398
3.441404 4.068152 4.451147 4.728161 4.94512 5.123289 5.274312 5.405274 5.520805 5.624103 5.717467 5.802605 5.880821 5.953135 6.020355 6.083137 6.142017 6.197442 6.249784 6.655859 6.93631 7.321691 7.58851 7.791864
3.426804 4.047322 4.425919 4.699496 4.913627 5.089393 5.238329 5.367445 5.481324 5.583127 5.675128 5.759012 5.83607 5.907307 5.973522 6.035361 6.093355 6.147942 6.199492 6.599383 6.875549 7.255065 7.51786 7.718171
3.381313 3.982475 4.347386 4.610249 4.81555 4.983801 5.126194 5.24952 5.358209 5.45531 5.543016 5.622949 5.69635 5.764185 5.82722 5.886076 5.941261 5.993196 6.042233 6.422446 6.684916 7.045614 7.295447 7.485943
3.336925 3.919289 4.270876 4.523279 4.719935 4.880808 5.016764 5.134379 5.237937 5.330382 5.413825 5.489831 5.55959 5.624031 5.683891 5.739763 5.792134 5.841408 5.887923 6.248272 6.496808 6.838217 7.074677 7.255005
3.293611 3.857719 4.196335 4.438526 4.62672 4.780351 4.909972 5.021955 5.12044 5.208271 5.287483 5.359581 5.425711 5.486765 5.543449 5.596332 5.645882 5.692483 5.73646 6.076705 6.311003 6.63252 6.855064 7.024744
3.251341 3.79772 4.123710 4.355936 4.535846 4.682371 4.805759 4.912186 5.005656 5.088916 5.163926 5.232137 5.29465 5.35232 5.405827 5.455715 5.502431 5.546346 5.587766 5.907625 6.127323 6.428201 6.636137 6.794545
3.210088 3.73925 4.052953 4.275453 4.447259 4.586812 4.70407 4.805019 4.893535 4.972266 5.043106 5.107451 5.166358 5.220651 5.270979 5.317867 5.36174 5.402952 5.441799 5.740974 5.945675 6.225059 6.417557 6.563915
3.169822 3.682268 3.984015 4.197027 4.360906 4.493624 4.604857 4.700411 4.784033 4.858286 4.924993 4.985497 5.040817 5.091743 5.138897 5.182782 5.223806 5.262307 5.298567 5.576798 5.766127 6.023168 6.199362 6.332834"""

q = np.array([map(float, L.split()) for L in q0975.split('\n')])
ch = np.array([map(float, L.split()) for L in ch0975.split('\n')])
rs = [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,30,40,60,80,100]
rs_mesh = np.array([rs for i in range(25)])
vs = [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,24,30,40,60,120,inf]
vs_mesh = np.array([list(t) for t in zip(*[range(1,1+len(vs)) for i in range(len(rs))])])

ch_ne = (ch-q)/q

from pprint import pprint as pp
pp([' '.join(['%.2f'%e for e in L]) for L in ch_ne*100])

##
##fig=pylab.figure()
##ax = p3.Axes3D(fig)
##ax.plot_wireframe(rs_mesh,vs_mesh,ch_ne)
##ax.set_xlabel('r')
##ax.set_ylabel('v')
##ax.set_zlabel('normalized error')
##pylab.show()
##fig.close()
